package com.sci.web.action.datareportseason.strategy;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import com.sci.web.action.util.BaseAction;
import com.sci.web.bean.Enterprise_Innovation;
import com.sci.web.dao.DataReportM_InnovateBaseDao;

/**
 * 插入一条新的文化创新数据
 * 
 * @author BaiFuyou
 * @date: Nov 11, 2011 10:17:01 AM
 */
public class AddNewEnterprise_Innovation extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5092801441273656890L;
	private int userId;
	private int type;
	private String innovation_exercise;
	private String innovation_staff_suggestion;
	private String innovation_idea;
	private String year;
	@Resource
	private DataReportM_InnovateBaseDao dataReportM_InnovateBaseDao;

	/**
	 * @return the userId
	 */
	public int getUserId() {
		return userId;
	}

	/**
	 * @param userId
	 *            the userId to set
	 */
	public void setUserId(int userId) {
		this.userId = userId;
	}

	/**
	 * @return the type
	 */
	public int getType() {
		return type;
	}

	/**
	 * @param type
	 *            the type to set
	 */
	public void setType(int type) {
		this.type = type;
	}

	/**
	 * @return the innovation_exercise
	 */
	public String getInnovation_exercise() {
		return innovation_exercise;
	}

	/**
	 * @param innovation_exercise
	 *            the innovation_exercise to set
	 */
	public void setInnovation_exercise(String innovation_exercise) {
		this.innovation_exercise = innovation_exercise;
	}

	/**
	 * @return the innovation_staff_suggestion
	 */
	public String getInnovation_staff_suggestion() {
		return innovation_staff_suggestion;
	}

	/**
	 * @param innovation_staff_suggestion
	 *            the innovation_staff_suggestion to set
	 */
	public void setInnovation_staff_suggestion(String innovation_staff_suggestion) {
		this.innovation_staff_suggestion = innovation_staff_suggestion;
	}

	/**
	 * @return the innovation_idea
	 */
	public String getInnovation_idea() {
		return innovation_idea;
	}

	/**
	 * @param innovation_idea
	 *            the innovation_idea to set
	 */
	public void setInnovation_idea(String innovation_idea) {
		this.innovation_idea = innovation_idea;
	}

	/**
	 * @return the year
	 */
	public String getYear() {
		return year;
	}

	/**
	 * @param year
	 *            the year to set
	 */
	public void setYear(String year) {
		this.year = year;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		super.setContentType(super.JSON);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("year", year);
		map.put("type", type);
		if (dataReportM_InnovateBaseDao.isExistBeforeEnterprise_InnovationInsert(map)) {
			super.outPrint("already");
			map.clear();
			return "json";
		}
		Enterprise_Innovation ei = new Enterprise_Innovation();
		ei.setEditable(1);
		ei.setEnterprise_id(dataReportM_InnovateBaseDao.getEnterpriseBaseId(userId));
		ei.setInnovation_check_pass(3);
		ei.setInnovation_exercise(innovation_exercise);
		ei.setInnovation_id(0);
		ei.setInnovation_idea(innovation_idea);
		ei.setInnovation_is_new(0);
		ei.setInnovation_staff_suggestion(innovation_staff_suggestion);
		ei.setInnovation_type(type);
		ei.setInnovation_year(year);
		if (dataReportM_InnovateBaseDao.insertNewEnterprise_InnovationData(ei)) {
			super.outPrint("ok");
		} else {
			super.outPrint("fail");
		}
		return "json";
	}
}
